/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package replica.communication;

import replica.transaction.TransactionStatus;
import java.io.Serializable;

/**
 *
 * @author Elena
 */
public class Messaggio implements Serializable{
    
    TransactionStatus status ;
    
    //The node related to this message
    Long nodeId;
    
    Long replicaHostId;
    
    
    Messaggio(TransactionStatus s, Long nodeId,Long replicaHostId)
    {
        this.status=s;
        this.nodeId=nodeId;
        this.replicaHostId=replicaHostId;
    }
    
    public TransactionStatus status(){
    return status;
    }
    
    public long getNodeId(){
    return nodeId;
    }
    
    public String toString()
    {
        return "[id="+nodeId+", status="+status+"]";
    }
    
    public static Messaggio buildMessaggioFromHost(TransactionStatus s, Long nodeId,Long replicaHostId)
    {
        return new Messaggio(s,nodeId,replicaHostId);
    }
    
    public static Messaggio buildMessaggioFromFrontEnd(TransactionStatus s, Long nodeId)
    {
        return new Messaggio(s,nodeId,null);
    }
    
}
    

